package DBHelper;

import exceptions.ObjectNotFoundException;
import java.math.BigInteger;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Object {
    private String name;
    private BigInteger objectId;
    private BigInteger parentId;
    private String description;
    
    public Object(BigInteger id) throws SQLException, ObjectNotFoundException {
        String query = "select * from objects where object_id = "+id;
        ResultSet rs = DBHelper.executeQuery(query);
        if (rs.next()) {
            while (rs.next()) {
                name = rs.getString("name");
                objectId = new BigInteger(rs.getString("object_id"));
                parentId = new BigInteger(rs.getString("parent_id"));
                description = rs.getString("description");
            }
        }
        else {throw new ObjectNotFoundException("Can't find object with id = "+id);}
    }
    
    public String getName() {
        return name;
    }
    public BigInteger getId() {
        return objectId;
    }
    public BigInteger getPerentId() {
        return parentId;
    }
    public String getDescription() {
        return description;
    }
}
